package com.ym521.simple;

import android.os.Bundle;
import android.util.Log;
import android.widget.ImageView;

import androidx.appcompat.app.AppCompatActivity;

import com.bumptech.glide.Glide;
import com.ym521.imgcrop.ImageCrop;
import com.ym521.imgcrop.base.CropType;
import com.ym521.imgcrop.widget.RectCropView;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ImageView imageView = findViewById(R.id.ivImageShow);
        ImageCrop crop = ImageCrop.getInstance().initCrop(this, result -> {
            Log.w("ImageCrop", result.toString());
            switch (result.getCode()) {
                case SUCCESS:
                    Glide.with(imageView).load(result.getImagePath()).into(imageView);
                    break;
                case CANCEL:

                    break;
                case FAIL:

                    break;
            }
        });
        findViewById(R.id.tvGridCrop).setOnClickListener((v) -> {
            crop.startCrop(R.drawable.ic_crop_test, CropType.GRID_CROP);
        });
        findViewById(R.id.tvRectCrop).setOnClickListener((v) -> {
            crop.startSelectCrop(R.drawable.ic_crop_test,0.8f);
        });
        findViewById(R.id.tvCircleCrop).setOnClickListener((v) -> {
            crop.startCrop(R.drawable.ic_crop_test, CropType.CIRCLE_CROP);
        });

    }
}